package com.example.controller;


import com.example.common.Result;
import com.example.entity.LiuyanMessage;
import com.example.entity.LiuyanMessageDTO;
import com.example.entity.User;
import com.example.service.AdminService;
import com.example.service.LiuYanService;
import com.example.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/liuyan")
public class LiuYanController {


    @Autowired
    LiuYanService liuYanService;






    /**
     * 新增
     */

    @PostMapping("/add")
    public Result add (@RequestBody LiuyanMessageDTO liuyanMessageDTO){
        liuYanService.add( liuyanMessageDTO);
        return Result.success();
    }

    /**
     * 删除
     */

    @DeleteMapping("/delete/{id}")
    public Result delete (@PathVariable Integer id){
        liuYanService.deleteById(id);
        return Result.success();
    }

    /**
     * 分页查询
     */
    @GetMapping("/selectPage")
    public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10")Integer pageSize,
                             Integer authorId, String authorName, String userRole){
        PageInfo<LiuyanMessage> PageInfo = liuYanService.selectPage(pageNum,pageSize, authorId, authorName, userRole);
        return Result.success(PageInfo);
    }




}
